Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add block cache trait #1192

Merged
merged 11 commits into from
Apr 1, 2024
Merged

Add block cache trait #1192

merged 11 commits into from
Apr 1, 2024

Conversation

Oscar-Pepper
Copy link
Contributor

@Oscar-Pepper Oscar-Pepper commented Feb 20, 2024

Adds a BlockCache trait for BlockSource which aims to generalise the block source for consumers who are not implementing an SQLite database. This lays some of the groundwork for #1184 by removing cyclic dependencies and generalising the sync engine for wallets with different implementations

Closes #1170

@Oscar-Pepper Oscar-Pepper force-pushed the add_block_cache_trait branch 3 times, most recently from ba0b06b to 7441a69 Compare February 23, 2024 14:38
rust-toolchain.toml Outdated Show resolved Hide resolved
…` with methods for managing a block cache.
@Oscar-Pepper Oscar-Pepper force-pushed the add_block_cache_trait branch from 523b152 to 1b4e5fa Compare March 4, 2024 16:56
@Oscar-Pepper Oscar-Pepper marked this pull request as ready for review March 4, 2024 18:34
@Oscar-Pepper
Copy link
Contributor Author

#1217 shows how this BlockCache trait is implemented into the #1184 sync engine

@zancas
Copy link
Contributor

zancas commented Mar 8, 2024

This looks ready to go! What's the protocol for approving a workflow?

Copy link

codecov bot commented Mar 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.76%. Comparing base (e795174) to head (7301c0c).
Report is 58 commits behind head on main.

❗ Current head 7301c0c differs from pull request most recent head 48e3ff1. Consider uploading reports for the commit 48e3ff1 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1192      +/-   ##
==========================================
+ Coverage   63.59%   63.76%   +0.16%     
==========================================
  Files         121      121              
  Lines       13945    14009      +64     
==========================================
+ Hits         8869     8933      +64     
  Misses       5076     5076              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Cargo.toml Outdated Show resolved Hide resolved
zcash_client_backend/Cargo.toml Outdated Show resolved Hide resolved
… tokio deps and moved tokio rt-multi-thread feature to dev-dependencies
daira
daira previously approved these changes Mar 11, 2024
Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK modulo documentation for short reads, if they are allowed.

 - Added read error documentation
 - Changed name of `cache_tip` method to `get_tip_height`
 - Improved doc comments
@Oscar-Pepper Oscar-Pepper force-pushed the add_block_cache_trait branch from 97611f1 to ea991b7 Compare March 12, 2024 15:03
@Oscar-Pepper Oscar-Pepper requested review from zancas and daira March 12, 2024 15:07
@Oscar-Pepper Oscar-Pepper requested a review from str4d March 12, 2024 15:07
Oscar-Pepper added a commit to Oscar-Pepper/librustzcash that referenced this pull request Mar 13, 2024
@zancas
Copy link
Contributor

zancas commented Mar 13, 2024

Oh hi! What needs to be done to approve this workflow?

daira
daira previously approved these changes Mar 14, 2024
Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@zancas
Copy link
Contributor

zancas commented Mar 14, 2024

I think this is ready to land. I think @Oscar-Pepper has already addressed @str4d 's requested changes.

Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed c62b5b2

zcash_client_backend/CHANGELOG.md Outdated Show resolved Hide resolved
zcash_client_backend/CHANGELOG.md Outdated Show resolved Hide resolved
zcash_client_backend/src/data_api/chain.rs Outdated Show resolved Hide resolved
zcash_client_backend/Cargo.toml Outdated Show resolved Hide resolved
@Oscar-Pepper Oscar-Pepper requested review from str4d and daira March 20, 2024 14:18
@zancas
Copy link
Contributor

zancas commented Mar 21, 2024

It looks like this workflow is ready to be kicked...

@Oscar-Pepper
Copy link
Contributor Author

Hi @str4d I've made the requested changes and it's ready for review again

Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed as of 7301c0c.

zcash_client_backend/src/data_api/chain.rs Outdated Show resolved Hide resolved
zcash_client_backend/src/data_api/chain.rs Outdated Show resolved Hide resolved

/// Inserts a vec of compact blocks into the block cache.
///
/// Returns `Ok(())` on success, otherwise returns an error.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document whether this should return an error if the blocks aren't contiguous. It probably doesn't matter here if they aren't, but we should make sure devs are clear on what the expected behaviour is here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not want to constrain an insert to a contiguous range of blocks and i will make that clear in the doc comment. I dont fully recall off the top of my head but there was a case where I realised, either from your current implemenation or a potential future optimisation, where it may be beneficial to be able to insert non-sequential ranges in one call.

zcash_client_backend/src/data_api/chain.rs Outdated Show resolved Hide resolved
zcash_client_backend/src/data_api/chain.rs Outdated Show resolved Hide resolved
zcash_client_backend/src/data_api/chain.rs Outdated Show resolved Hide resolved
@Oscar-Pepper Oscar-Pepper requested a review from str4d March 30, 2024 12:01
@Oscar-Pepper
Copy link
Contributor Author

Reviewed as of 7301c0c.

Hi @str4d, thanks for the review, I have replied to and made all requested changes except for adding &mut which we should discuss if its felt this is neccessary as its not clear to me how to implement 1169-sync-engine this way or further concurrent optimisations.

I have sent for review again.

Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK. There are some further changes I want to make (like placing this behind a feature flag), but I can do that when I rebase #1184 on top of this.

@str4d str4d merged commit 25b8404 into zcash:main Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zcash_client_backend: Add cache insertion and deletion APIs to BlockSource trait or a new trait
6 participants